#ifndef SNAKE_H
#define SNAKE_H

#include <vector>
#include "map.h"

enum class Direction
{
    Up = 0,
    Down = 1,
    Left = 2,
    Right = 3, 
};

class SnakeBody
{
public:
    SnakeBody();
    SnakeBody(int x, int y);
    int getX() const;
    int getY() const;
    Direction getDirection() const;
    void setDirection(Direction D);
    bool operator == (const SnakeBody& snakeBody);
private:
    int mX;
    int mY;
    Direction bodyDirection = Direction::Up;
};

// Snake class should have no depency on the GUI library
class Snake
{
public:
    //Snake();
    Snake(Map GameMap);
    // Set random seed
    void setRandomSeed();
    // Initialize snake
    void initializeSnake();
    // Checking API for generating random food
    bool isPartOfSnake(int x, int y);
    int touchFood();
    void senseFood(std::vector<point> Foods);
    // Check if the snake is dead
    bool hitWall();
    bool hitSelf();
    bool checkCollision();

    bool changeDirection(Direction newDirection);
    std::vector<SnakeBody>& getSnake();
    int getLength();
    SnakeBody createNewHead();
    int moveFoward();

private:
    int mGameBoardWidth;
    int mGameBoardHeight;
    // Snake information
    const int mInitialSnakeLength = 3;
    Direction mDirection;
    std::vector<point> mFoods;
    std::vector<SnakeBody> mSnake;
    Map mGameMap;
    std::map<std::string, double> mMap;
    const std::vector<point> mBarriers = mGameMap.getBarriers();
};

#endif
